﻿/// <reference path="../GeneratedArtifacts/viewModel.js" />
myapp.Order.created = function (entity) {
    // Set Default Date
    entity.OrderDate = new Date();
};

// Calculated field to count Available OrderDetails
myapp.Order.prototype.getAvailable = function () {
    return this.OrderDetails.sum(function (item) {
        return item.ItemAvailable == true;
    });
};

// Calculated field to count UnAvailable OrderDetails
myapp.Order.prototype.getUnAvailable = function () {
    return this.OrderDetails.sum(function (item) {
        return item.ItemAvailable == false;
    });
};
